package router

import (
	"github.com/gin-gonic/gin"
	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
	"tuowei.com/app/api/apis"
	"tuowei.com/common/middleware"
)

func init() {
	routerNoCheckRole = append(routerNoCheckRole, payRouter)
	routerCheckRole = append(routerCheckRole, transferRouter)

}

func transferRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	wxauth := v1.Group("/wxpay").Use(authMiddleware.MiddlewareFunc()).Use(middleware.CheckLogin)
	wx := apis.ApiWxPay{}
	wxauth.POST("/transfer", wx.Transfer)
}

func payRouter(v1 *gin.RouterGroup) {
	ali := apis.AliPay{}
	wx := apis.ApiWxPay{}
	pay := apis.Pay{}
	v1auth := v1.Group("/alipay")
	{
		v1auth.POST("/pay", ali.Pay)
		//todo 未测试
		v1auth.Any("/callback", ali.Notify)
	}
	wxauth := v1.Group("/wxpay")
	{
		wxauth.POST("/pay", wx.Pay)
		//todo 未测试
		wxauth.Any("/callback", wx.Notify)
	}
	v1.POST("/pay", pay.Pay)
}
